﻿var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require("path");
module.exports = {
    entry: "./js/main.js", /*模块的入口文件*/
    output: {
        /*模块的输出文件*/
        path: __dirname, /*打包文件的绝对路径*/
        filename: "app.js"/*文件名*/
    },
    module: {
        loaders: [
            {test: /\.html$/, loader: "html"}, /*html文件加载器*/
            {test: /\.css$/, loader: "style!css"}, /*css文件加载器*/
            {
                test: /\.(jpg|png|gif)$/,
                loader: "url?limit=8&name=img/[name].[hash:8].[ext]"
            }/*图片模块加载器 小于8k的文件转换为base64形式 8192*/
        ]
    },
    resolve: {
        extensions: ["", ".html", ".css", ".js"] /*自动扩展文件的后缀名，比如我们在require模块的时候，可以不用写后缀名的*/
    },
    plugins: [
        /*插件选项*/
        new HtmlWebpackPlugin({
            filename: "index.html",
            template: "templete.html",
            inject: true,
            hash: true,
            minify: {
                removeComments: true,
                removeCommentsFromCDATA: true,
                collapseWhitespace: true,
                collapseBooleanAttributes: true,
                removeAttributeQuotes: true,
                removeRedundantAttributes: true,
                removeEmptyAttributes: true,
                removeOptionalTags: true
            }
        })
    ]
};